package com.bwie.controller;

import com.bwie.pojo.TbUser;
import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.ForgetVo;
import com.bwie.vo.LoginInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author : Yoo19
 * @description :
 * @createDate : 2025/7/15 9:05 05
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private TbUserService tbUserService;

    /**
     * 登陆方法
     * @param loginInfoVo
     * @return
     */
    @ApiOperation("登陆")
    @PostMapping("/login")
    public R login(@RequestBody LoginInfoVo loginInfoVo){
        return tbUserService.login(loginInfoVo);
    }

    /**
     * 用户注册
     * @param tbUser
     * @return
     */
    @ApiOperation("注册")
    @PostMapping("/register")
    public R register(@RequestBody @Validated TbUser tbUser){
        return tbUserService.register(tbUser);
    }

    /**
     * 发送手机验证码
     * @param mobile
     * @return
     */
    @ApiOperation("发送验证码")
    @PostMapping("/sendCode/{mobile}")
    public R sendCode(@PathVariable("mobile")String mobile){
        return tbUserService.sendCode(mobile);
    }


    @ApiOperation("忘记密码")
    @PostMapping("/forget")
    public R forget(@RequestBody ForgetVo forgetVo){
        return tbUserService.forget(forgetVo);
    }
}
